<?php
class LetterStationServer {
	public function batchSend($userData,$sendInfo){
		if (empty($userData)){
			return ERROR_CODE_ONE;
		}
		$tmp = array();
		$time = time();
		$info = HttpServerManager::getSendInfoTemplateServer()->getTitleAndContent($sendInfo);

		if (!is_array($info)){
			return $info;
		}
		foreach ($userData as $v){
			$tmp1['user_id'] = $v['id'];
			$tmp1['time'] = $time;
			$tmp1['title'] = $info['title'];
			$tmp1['sender'] = '管理员';
			$tmp1['content'] = $info['content'];
			array_push($tmp,$tmp1);
		}
		HttpDaoManager::getLetterStationDao()->addArray($tmp);
		return true;
	} 
	public function  paging($where=array(),$numberEachPage = 10){
		$count = HttpDaoManager::getLetterStationDao()->count($where);
		$page = new Page($count, $numberEachPage);
		$limit[0]= $page->which;
		$limit[1]=$numberEachPage;
		$list = HttpDaoManager::getLetterStationDao()->getList($where,'',$limit);
		$page1= $page->returnPage("?".ClassManager::getToos()->combinationGet('page')."&page=");
		$data['list'] =$list;
		$data['page'] = $page1;
		return $data;
		
	}
	public function markRead($id){
		$letterStationDao = HttpDaoManager::getLetterStationDao();
		$data = $letterStationDao->get($id);
		if (!($data['status'] ===STATION_STATUS_1)){
			$letterStationDao->update(array('status'=>STATION_STATUS_1), $id);
		}
	}
	
}

?>